package cn.gailvlun.gll.presentation.emotion;

import android.content.Context;

import com.github.markzhai.recyclerview.MultiTypeAdapter;

import java.util.List;

import cn.gailvlun.gll.R;
import cn.gailvlun.gll.net.emotion.Comment;



@Deprecated
public class EmotionDetailAdapter extends MultiTypeAdapter {
    public EmotionDetailAdapter(Context context) {
        super(context);
        addViewTypeToLayoutMap(Type.EMPTY.ordinal(), R.layout.item_emotion_empty);
        addViewTypeToLayoutMap(Type.EMOTION.ordinal(), R.layout.item_emotion_detail_emotion);
        addViewTypeToLayoutMap(Type.COMMENT_HEADER.ordinal(), R.layout.item_emotion_detail_comment_header);
        addViewTypeToLayoutMap(Type.COMMENT.ordinal(), R.layout.item_emotion_detail_comment);
    }


    public enum Type {
        EMOTION,
        COMMENT_HEADER,
        COMMENT,
        EMPTY
    }

    public void removeByViewType(Type type) {
        for (int i = 0; i < mCollectionViewType.size(); ++i) {
            if (mCollectionViewType.get(i) == type.ordinal()) {
                mCollectionViewType.remove(i);
                mCollection.remove(i);
                notifyItemRemoved(i);
            }
        }
    }

    public void removeComment(Comment comment) {
        for (int i = 0; i < getItemCount(); i++) {
            if (mCollection.get(i).equals(comment)) {
                mCollection.remove(i);
                notifyItemRemoved(i);
            }
        }
    }

    public int findFirstPositionByViewType(Type type) {
        for (int i = 0; i < mCollectionViewType.size(); ++i) {
            if (mCollectionViewType.get(i) == type.ordinal()) {
                return i;
            }
        }
        return -1;
    }

    public List getData() {
        return mCollection;
    }

}
